<?php
/*
	@version		$Id: template_config.php 20-09-2007 Waseem Sadiq $
	@copyright		Copyright (C) 2007-2010 Waseem Sadiq. All rights reserved.
	@license		Single Domain License
*/


/*
	Additional Template Functionality

	@package		Joomla!
	@subpackage		1.5
	@version		1.5
*/

/* 
	Make sure Joomla is calling this page 
*/
defined('_JEXEC') or die('Restricted access');

/* 
	Define the path to our template's css, images and javascript folders
*/
$style_url = $this->baseurl . '/templates/' . $this->template . '/css';
$script_url = $this->baseurl . '/templates/' . $this->template . '/javascript';
$img_url = $this->baseurl . '/templates/' . $this->template . '/images';

/*
	Set edit mode
*/
$editmode = false;
if (JRequest::getCmd('task') == 'edit' ) :
	$editmode = true;
endif;

/* 
	check if left or right modules are published 
*/
$leftcolumn = $this->countModules('left or syndicate');
$rightcolumn = ($this->countModules('right') and JRequest::getCmd('layout') != 'form' and !$editmode );

$left = ($leftcolumn ? 1 : 0);
$right = ($rightcolumn ? 1 : 0);

/* Set style type based on column layout */
if ($left &! $right) $style 	= "left-only";
if (!$left && $right) $style 	= "right-only";
if (!$left &! $right) $style 	= "wide";
if ($left && $right) $style 	= "both";

#---------------------paramterized custom widths------------------------------#
								 
$leftcolumn_width = ($this->countModules('left')>0) ? $leftcolumn_width : 0;
$rightcolumn_width = (!$editmode and $this->countModules('right')>0) ? $rightcolumn_width : 0;
	
	/*load first container*/
if (($unit_measure == "px") && ($style != "both")) 
	$load_first = ($template_width - $rightcolumn_width);
if (($unit_measure == "px") && ($style == "both")) 
	$load_first = ($template_width - $rightcolumn_width) . $unit_measure .'!important; width:'. ($template_width - $rightcolumn_width - 20);

if (($unit_measure == "%") && ($template_width == 100)) 
	$load_first = ($template_width - $rightcolumn_width);
if (($unit_measure == "%") && ($template_width < 100)) 
	$load_first = (100 - $rightcolumn_width);

	/*middle column*/	
if (($unit_measure == "px") && ($style == "both"))
	$middle_col = ($template_width - $leftcolumn_width - $rightcolumn_width) . $unit_measure .'!important; width:'. ($template_width - $rightcolumn_width - 20);
if (($unit_measure == "px") && ($style == "left-only"))	
	$middle_col = ($template_width - $leftcolumn_width);
if (($unit_measure == "px") && ($style == "right-only"))	
	$middle_col = ($template_width - $rightcolumn_width);
if (($unit_measure == "px") && ($style == "wide"))	
	$middle_col = $template_width;
	
if (($unit_measure == "%") && ($style == "right-only"))
	$middle_col = 100;
if (($unit_measure == "%") && ($template_width == 100) && ($style != "right-only")) 	
	$middle_col = ($template_width - $leftcolumn_width);
if (($unit_measure == "%") && ($template_width < 100) && ($style != "right-only")) 	
	$middle_col = (100 - $leftcolumn_width);	

$template_width = 'width: ' . $template_width . $unit_measure;
$load_first = 'width: ' . $load_first . $unit_measure;
$middle_col = 'width: ' . $middle_col . $unit_measure;
$leftcolumn_width = 'width: ' . $leftcolumn_width . $unit_measure;
$rightcolumn_width = 'width: ' . $rightcolumn_width . $unit_measure;

	/*style output*/
$inlinestyle = "
	#container {".$template_width."}
	#nav {".$template_width."}
	#load-first{ ". $load_first ."}
	#middle-column{". $middle_col ."}
	#left {". $leftcolumn_width ."}
	#right {". $rightcolumn_width ."}
";

#--------------------------------------------------------------------------#
	
/* 
	Count the number of top teaser modules
	edit these lines to indicate which modules are in the top teaser block 
*/
$firsttopmodule = $this->countModules('user1');
$secondtopmodule = $this->countModules('user2');
$thirdtopmodule = $this->countModules('user3');
$fourthtopmodule = $this->countModules('user4');

#--------------------------------------------------------------------------#

$topmodule1 = ($firsttopmodule ? 1 : 0);
$topmodule2 = ($secondtopmodule ? 1 : 0);
$topmodule3 = ($thirdtopmodule ? 1 : 0);
$topmodule4 = ($fourthtopmodule ? 1 : 0);

$toptotal = ($topmodule1 + $topmodule2 + $topmodule3 + $topmodule4);

#--------------------------------------------------------------------------#

/* 
	Count the number of bottom teaser modules
	edit these lines to indicate which modules are in the bottom teaser block
*/
$firstbottommodule = $this->countModules('user5');
$secondbottommodule = $this->countModules('user6');
$thirdbottommodule = $this->countModules('user7');
$fourthbottommodule = $this->countModules('user8');

#--------------------------------------------------------------------------#

$bottommodule1 = ($firstbottommodule ? 1 : 0);
$bottommodule2 = ($secondbottommodule ? 1 : 0);
$bottommodule3 = ($thirdbottommodule ? 1 : 0);
$bottommodule4 = ($fourthbottommodule ? 1 : 0);

$bottomtotal = ($bottommodule1 + $bottommodule2 + $bottommodule3 + $bottommodule4);

#--------------------------------------------------------------------------#

/*
	Check if there's a page specific stylesheet and if there is return the link to the CSS file
*/
function getPageCssFile (){
global $mainframe;

$template = $mainframe->getTemplate();
$pagecssfile = "";

/*
	set the location of the page specific CSS file
	eg: the following line of code = templatepath\current-template\css\pageNUMBER.css
*/
$page_specific_css_file = JPATH_THEMES.DS. $template .DS.'css'.DS.'page'. JRequest::getInt('Itemid', 0) .'.css';

/*
	Check to see if the page specific CSS file exists
*/
	if (file_exists($page_specific_css_file)) 

/*
	If the file exists output the link to the file
*/
	{

/*	
	edit the file path if you use a different folder for your page-specific CSS files
	eg: the following line of code = http://www.yourwebsite.com/templates/current-template/css/pageNUMBER.css
*/
	$pagecssfile = '<link href="'. JURI::base() .'templates/' . $template .'/css/page' . JRequest::getInt('Itemid', 0) .'.css" rel="stylesheet" type="text/css" media="screen" />';
}
	return $pagecssfile;
}

#--------------------------------------------------------------------------#
// Function to return the item ID of the page we are viewing

function getPageId()
{
   return JRequest::getInt('Itemid', 0);
}

?>
